const tools = {
  formatDate: (date: any, formater: any) => {
    if (!date) {
      return "-- : --";
    }
    date = date.toString().replace(/-/g, "/");
    const nowDate = new Date(date);
    const year: any = nowDate.getFullYear();
    let month: any = nowDate.getMonth() + 1;
    month = month < 10 ? "0" + month : month;
    let day: any = nowDate.getDate();
    day = day < 10 ? "0" + day : day;
    let hour: any = nowDate.getHours();
    hour = hour < 10 ? "0" + hour : hour;
    let minute: any = nowDate.getMinutes();
    minute = minute < 10 ? "0" + minute : minute;
    let second: any = nowDate.getSeconds();
    second = second < 10 ? "0" + second : second;
    let _after = year + "-" + month + "-" + day;
    let week: any = nowDate.getDay();
    const weeks = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
    week = weeks[week];
    if (formater) {
      _after = formater
        .replace("yyyy", year)
        .replace("MM", month)
        .replace("dd", day)
        .replace("HH", hour)
        .replace("mm", minute)
        .replace("ss", second)
        .replace("week", week);
    }
    return _after;
  },
};
export default tools;
